﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Common.Logging;

namespace Efficient.DataAccess
{
    /// <summary>
    /// 内置只读事务，只是保存了数据库连接对象
    /// </summary>
    internal class ReadOnlyTransaction : IDbTransaction
    {
        protected static readonly ILog logger = LogManager.GetLogger(typeof(QueryImpl));
        private readonly IDbConnection connection;
        public ReadOnlyTransaction(IDbConnection connection)
        {
            this.connection = connection;
        }
        #region IDbTransaction Members

        public void Commit()
        {
            if (logger.IsInfoEnabled)
            {
                logger.Info("Commit");
            }
        }

        public IDbConnection Connection
        {
            get { return this.connection; }
        }

        public IsolationLevel IsolationLevel
        {
            get { return IsolationLevel.Unspecified; }
        }

        public void Rollback()
        {
            if (logger.IsInfoEnabled)
            {
                logger.Info("Rollback");
            }
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            if (logger.IsInfoEnabled)
            {
                logger.Info("Dispose");
            }
        }

        #endregion
    }
}
